<?php namespace Common\Model;
use \Hdphp\Model\Model;
class commodity extends Model
{
	protected $table = "commodity";
	protected $validate = array(
		array("com_name","required","请填写商品名称",3,3),
		array("stock","required","请填写商品库存",3,3),
		array("oldprice","required","请填写商品原价",3,3),
		array("nowprice","required","请填写商品现价",3,3),
	);
	protected $auto =array(
		array('sendtime','time','function',3,1),
		array('resettime','time','function',3,2),
	);
	//添加商品
	public function addcom()
	{
		if(!$this->create()) return FALSE;
		
		//添加操作人员id和类型id
		$this->staff_sid = $_SESSION['sid'];
		$cid = $_POST['category_cid'];
		$tid = Db::table("category")->where('cid',$cid)->pluck('type_tid');
		$this->type_tid = $tid;
		//p($_POST);die;
		return $this->add();
	}
}
